<?php

class Photo_Api_Photo
{
	/**
	 * setcover from resource photo url
	 * @param Model_Database_Item $resource
	 * @param Storage_Table_File $photo
	 */
	function setCover($resource, $photo)
	{
		$table = Nuo::getTable('photo/cover');
		$item = $table -> find($resource -> getItemId()) -> current();
		if (!$item)
		{
			$item = $table -> fetchNew();
			$item -> resource_id = $resource -> getItemId();
		}
		$item -> setPhotoFile($photo);

		$item -> save();

		return $item;
	}

	function getCover($resource)
	{
		$table = Nuo::getTable('photo/cover');
		return $table -> find($resource -> getItemId()) -> current();
	}

	function addNew($resource, $poster, $data)
	{

	}

}
